# 测试写，自动关闭方式
def w_test(file_path):
    with open(file_path, "w") as file:
        file.write("你好，欢迎回家")


# 测试读，自动关闭方式
def r_test(file_path):
    with open(file_path, "r") as file:
        print(file.read())


# 复制，自动关闭方式
def copy_test(file_path, dest_path):
    with open(file_path, 'r') as src:
        with open(dest_path, "w") as dest:
            dest.write(src.read())


if __name__ == '__main__':
    w_test("2.txt")
    r_test("2.txt")
    copy_test("2.txt", "2bak.txt")
